
package com.ami.kvm.jviewer.kvmpkts;

import com.ami.kvm.jviewer.Debug;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public class CfgBandwidth {
	public static final int BANDWIDTH_100MBPS = 13107200;
	public static final int BANDWIDTH_10MBPS = 1310720;
	public static final int BANDWIDTH_1MBPS = 131072;
	public static final int BANDWIDTH_512KBPS = 65536;
	public static final int BANDWIDTH_256KBPS = 32768;
	public static final int CFG_BANDWIDTH_SIZE = 4;
	public IVTPPktHdr m_vHdr;
	public int m_bandwidth;
	ByteBuffer m_repBuf;
	private byte[] m_report;

	public CfgBandwidth(int paramInt) {
		this.m_bandwidth = paramInt;
		this.m_report = new byte[12];

		this.m_vHdr = new IVTPPktHdr((short) 2, 4, (short) 0);

		this.m_repBuf = ByteBuffer.wrap(this.m_report);
		this.m_repBuf.order(ByteOrder.LITTLE_ENDIAN);
		this.m_repBuf.limit(this.m_report.length);
	}

	public int size() {
		return 12;
	}

	public byte[] report() {
		this.m_repBuf.position(0);

		this.m_repBuf.put(this.m_vHdr.array());

		this.m_repBuf.putInt(this.m_bandwidth);
		return this.m_report;
	}

	public static int determineBandwidth(long paramLong) {
		double d1 = paramLong / 1000.0D;

		double d2 = 1.31072E7D / d1;
		Debug.out.println("bps " + d2);

		if (d2 < 49152.0D) {
			return 32768;
		}
		if (d2 < 98304.0D) {
			return 65536;
		}
		if (d2 < 720896.0D) {
			return 131072;
		}
		if (d2 < 7208960.0D) {
			return 1310720;
		}

		return 13107200;
	}
}

/*
 * Location:
 * D:\Users\tianlin\Downloads\JViewer.jar!\com\ami\kvm\jviewer\kvmpkts\
 * CfgBandwidth.class Java compiler version: 5 (49.0) JD-Core Version: 0.7.1
 */